//当前这个模块，API进行统一管理、
import request from './request'
import mockRequest from './mockRequest'


//三级联动接口
//获取商品分类
export const reqCategoryList = () => {
    //发请求:axios发请求返回结果Promise对象
    return request({ url: '/api/getCateGoryList', method: 'get' }) //request中的baseURl加了api，所以这里的url地址前面不用写api
}

//获取banner (Home轮播图接口)
export const reqGetBannerList = () => {
    //发请求:axios发请求返回结果Promise对象
    return mockRequest({ url: '/banner', method: 'get' }) //request中的baseURl加了api，所以这里的url地址前面不用写api
}

//获取floor数据
export const reqFloorList = () => {
    //发请求:axios发请求返回结果Promise对象
    return mockRequest({ url: '/floor', method: 'get' }) //request中的baseURl加了api，所以这里的url地址前面不用写api
}

//用户注册
export const reqUserRegister = (data) => {
    // return request({ url: `/user/passport/register`, data, method: 'post' })
    return request({ url: `api/reguser`, data, method: 'post' })
}


//获取注册验证码
export const reqGetCode = (data) => {
    // return request({ url: `/user/passport/sendCode/${phone}`, method: 'GET' })
    return request({ url: `api/getphonecode`, data, method: 'post' })
}

//登录
//method：POST phone、password
export const reqUserLogin = (data) => {
    return request({ url: `api/login`, data, method: 'post' })
}

//获取用户信息(需要带着用户的token向服务器要用户信息)
export const reqUserInfo = () => {
    return request({ url: `my/getUserinfo`, method: 'get' })
}

//退出登录
export const reqlogout = () => {
    return request({ url: `api/logout`, method: 'GET' })
}

//获取搜索模块数据    请求方式：post 参数：需要带参数
export const reqGetSearchInfo = (params) => {
    return request({ url: 'api/getGoodsList', method: 'post', data: params })
}
//获取根据分类获取商品   
export const reqGetGoodsByCategory = (cateGoryList) => {
    return request({ url: 'api/getGoodsListByCategory', data:cateGoryList,method: 'post',})
}

//获取产品详情信息 请求方式：get 参数：需要带参数
export const reqGoodsInfo = (skuId) => {
    return request({ url: `api/getGoodsDetail/${skuId}`, method: 'get' })
}

//获取购物车数据 请求方式：get  参数：需要带参数 
export const reqCarList = () => {
    return request({ url: `my/getCartList`, method: 'get' })
}

//将产品添加到购物车中（获取更新某一个产品的个数）
//请求方式：post 参数：需要带参数
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    return request({ url: `my/addOrUpdateCart/${skuId}/${skuNum}`, method: 'post' })
}

//将购物车中产品删除
export const reqDeleteCartById = (skuId) => {
    return request({ url: `/my/deleteCart/${skuId}`, method: 'DELETE' })
}

//购物车产品选中状态
export const reqUpdateCheckedById = (skuId, isChecked) => {
    return request({ url: `/my/checkCart/${skuId}/${isChecked}`, method: 'GET' })
}

//获取商品清单
//地址:/api/order/auth/trade    method:get
export const reqOrderInfo = () => {
    return request({ url: '/my/getOrder', method: 'get' })
}


//提交订单接口
//地址：/api/order/auth/submitOrder?tradeNo={tradeNo}    method:post
export const reqSubmitOrder = (tradeNo, data) => {
    // return request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })
    return request({ url: `/my/submitOrder/${tradeNo}`, data, method: 'post' })
}

//获取支付信息
//地址：/api/payment/weixin/createNative/{orderId}  method:GET
export const reqPayInfo = (orderId) => {
    return request({ url: `/my/getOrderInfo/${orderId}`, method: 'get' })
}

//更新订单支付状态
export const reqUpdateOrderIsPay = (orderId) => {
    return request({ url: `/my/updateOrder/${orderId}`, method: 'get' })
}


//获取我的订单数据
//地址：/api/order/auth/{page}/{limit}      method:GET
export const reqMyOrderList = () => {
    return request({ url: `/my/getOrderByUserId`, method: 'get' })
}
// <------------------------------------------------------------->



// //获取用户地址信息
// // 地址：/api/user/userAddress/auth/findUserAddressList     method:get
// export const reqAddressInfo = () => {
//     return request({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
// }


// //获取支付订单状态（支付成功|失败）
// //地址：/api/payment/weixin/queryPayStatus/{orderId}    method:GET
// export const reqPayStatus = (orderId) => {
//     return request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })
// }
